var util = require('../../../../utils/util.js');
var api = require('../../../../config/api.js');
var app = getApp();

Page({
  data: {
    mendianList: [],
  },
  onLoad: function (options) {
    // 页面初始化 options为页面跳转所带来的参数
  },
  onReady: function () {
    // 页面渲染完成
  },
  onShow: function () {
    // 页面显示
    this.getMendianList();
  },
  getMendianList() {
    let that = this;
    util.request(api.MendianList).then(function (res) {
      if (res.result == 1) {
        that.setData({
          mendianList: res.data
        });
      }
    });
  },
  selectmendian(event) {
    //返回之前，先取出上一页对象，并设置mendianId
    var pages = getCurrentPages();
    var prevPage = pages[pages.length - 2];
    if (prevPage.route == "pages/order/order" || prevPage.route == "pages/marketing/mtorder/mtorder") {
      try {
        wx.setStorageSync('mendianid', event.currentTarget.dataset.mendianid);
      } catch (e) {

      }
      let mendianid = event.currentTarget.dataset.mendianid;
      if (mendianid && mendianid != '') {
        wx.navigateBack();
      }
    }
  },
  //点击电话图标
  tel: function () {
    wx.makePhoneCall({
      phoneNumber: '13242720897',
    })
  },
  onHide: function () {
    // 页面隐藏
  },
  onUnload: function () {
    // 页面关闭
  }
})